package pl.org.lutra.planner;

import java.util.Observable;

import pl.org.lutra.planner.log.Log;
import pl.org.lutra.planner.model.Model;
import pl.org.lutra.planner.model.ModelFactory;
import pl.org.lutra.planner.model.ModelObserverEvent;
import pl.org.lutra.planner.model.data.Plan;
import pl.org.lutra.planner.model.input.Input;

public class Planner extends Observable {
	private static final Planner INSTANCE = new Planner();

	private Input input = new Input();
	private Model model = ModelFactory.createModel();

	private Planner() {
		addObserver(input);
	}

	public static Planner getInstance() {
		return INSTANCE;
	}

	public Input getInput() {
		return input;
	}

	public void calculate() {
		Log.debug("Calculation started");

		model.calculate(input.getDive());

		input.update(this, ModelObserverEvent.CALCULATION_FINISHED);
		Log.debug("Calculation stopped");
	}

	public Plan getResult() {
		return model.getPlan();
	}

}
